package old;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.KeyFactory;

public class SuprimerMembreServlet extends HttpServlet {

	private static final long serialVersionUID = 8573754054601066327L;
	public void doPost(HttpServletRequest req, HttpServletResponse resp)	throws IOException {
		resp.setContentType("text/plain");
		String  selection = req.getParameter("selection");
		if(selection!=null){
			Key key = KeyFactory.createKey("Membres",selection);
			DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
			try {
				System.out.println(datastore.get(key).getProperty("nom"));
			} catch (EntityNotFoundException e) {
				e.printStackTrace();
			}
			datastore.delete(key);
			resp.sendRedirect("/panneauAdministration/membres.jsp");
		}else{
			resp.sendRedirect("/panneauAdministration/membres.jsp");
		}
	}

}
